<?php

	//we need to get all of the modes, and check that the user has permission for that mode here?
	$modeSelectArray = array();
	$currentMode = null;
	$userModes = modesForUserId($authInfo->uid, $db);
	foreach ($userModes as $mode) {
		$modeSelectArray[$mode->modecode] = $mode->modemask;
		if ($viewMode == $mode->modemask)
			$currentMode = $mode;
	}
	$labelLocation="cms";
	if (!in_array( $currentMode->modecode, array("intranet","cms","mailout","site","admin","",null))){
		$labelLocation = "site";
	}
?>
<div id="cms_viewmode">
	<div id="cms_videmode_modedisplay">
		<img src="/<?=$labelLocation?>/images/mode_<?= $currentMode->modecode ?>.gif" />
	</div>	
	<div class="cms_viewmode_selectlinks">
<?
	$i =0;
	$c = count($modeSelectArray);

	foreach ( $modeSelectArray as $key => $value ) {
		
		//icons to show..
		$id = "cms_viewmode_" . $key ;//. $iconSelection;
		$cmsHome = CMS_HOME;


//if we are not a default site, we need to 		
	$iconLocation = "cms";
	if ( !in_array($key, array("intranet","cms","mailout","site","admin","",null)) ) { //cms, mailout, admin, site - these are the defaults.. all others really need to come from elsewhere..
		$iconLocation = "site";
	}
//echo $key ." - ". $value;
//
?>
			<a style="background: url(/<?= $iconLocation ?>/images/menu_<?=$key?><?if($currentMode->modecode == $key) echo "_on";?>.gif) no-repeat 0px 0px;" href="<?=$cmsHome?>?viewModeSent=<?=$value?>&fileNo=13" id="<?=$id?>"><img width="40" height="26" src="/cms/images/spacer.gif" /></a>
<?
		//where to put the dividers
		if ( $c> 1  && $i < $c -1 ) {
			print <<< EOD
			<img width="6" height="26" src="/cms/images/nav_divider.gif" />		
EOD;
		}
		$i++;
	}
		
?>	<img src="/cms/images/mode_select.jpg" />

</div>	
</div>